//
//  TXFStatuesCell.swift
//  weibo飞飞
//
//  Created by 田侠飞 on 16/6/27.
//  Copyright © 2016年 田侠飞. All rights reserved.
//

import UIKit
import SnapKit
class TXFStatuesCell: UITableViewCell {
    
    
    var statuesChildViewContaint: Constraint?
    //将模型数据拿过来
    
    var status : TXFStatues? {
        
        didSet{
            
            //可以复制
            txfStatuesFirstView.status  = status
            
            txfStatuesTwoView.status = status
            
            txfStatuesThreeView.status = status
            
            
            
            
            statuesChildViewContaint?.uninstall()
            
            if status?.retweeted_status == nil{
            
            txfStatuesThreeView.hidden = true
            
                txfStatuesTwoView.snp_makeConstraints { (make) -> Void in
                    statuesChildViewContaint = make.top.equalTo(txfStatuesFirstView.snp_bottom).constraint
                    
                }
                

            
            }else{
            
            txfStatuesThreeView.status = status
            txfStatuesThreeView.hidden = false
                
                txfStatuesTwoView.snp_makeConstraints { (make) -> Void in
                    statuesChildViewContaint = make.top.equalTo(txfStatuesThreeView.snp_bottom).constraint
                    
                }
            }
        }
        
        
    }
   override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
    setupUI()
    //布局:
    }

   required init?(coder aDecoder: NSCoder) {
       fatalError("init(coder:) has not been implemented")
   }

    func setupUI(){
        
    self.backgroundColor = UIColor.whiteColor()
        
        
    contentView.addSubview(txfStatuesFirstView)
    contentView.addSubview(txfStatuesTwoView)
    contentView.addSubview(txfStatuesThreeView)
    txfStatuesFirstView.snp_makeConstraints { (make) -> Void in
            
         make.top.leading.right.equalTo(contentView)
        //已经动态设置宽度:
        //make.height.equalTo(50)
        
        }

     txfStatuesThreeView.snp_makeConstraints { (make) -> Void in
        
        make.top.equalTo(txfStatuesFirstView.snp_bottom)
        make.leading.right.equalTo(contentView)
//        make.height.equalTo(50)
        }
        
     txfStatuesTwoView.snp_makeConstraints { (make) -> Void in
        statuesChildViewContaint = make.top.equalTo(txfStatuesThreeView.snp_bottom).constraint
            make.leading.right.equalTo(contentView)
            //已经动态设置宽度:
            make.height.equalTo(35)
        
        }
    
      contentView.snp_makeConstraints { (make) -> Void in
        
        make.top.left.right.equalTo(self)
        make.bottom.equalTo(txfStatuesTwoView)
        
        
        }
        
    }
    
    //懒加载:(添加一个View)
    
    
    private lazy var txfStatuesFirstView : TXFStatuesFirstView = TXFStatuesFirstView()
    
    //创建toolBarview
    
    private lazy var txfStatuesTwoView : TXFStatuesTwoView = TXFStatuesTwoView()
    
    private lazy var txfStatuesThreeView : TXFStatuesThreeView = TXFStatuesThreeView()
}











